package org.kwin.tomcat.servlet.http;

import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.http.HttpRequest;
import io.netty.handler.codec.http.QueryStringDecoder;
import org.kwin.tomcat.servlet.ServletRequest;

import java.util.Arrays;
import java.util.Enumeration;
import java.util.List;
import java.util.Map;

/**
 * @author : wangkai
 * @version V1.0
 * @Package org.kwin.tomcat.servlet.http
 * @Description:
 * @date 2021年10月12日 9:27
 **/
public class HttpServletRequest implements ServletRequest {
    
    private HttpRequest req;
    
    public HttpServletRequest( HttpRequest req)
    {
        this.req = req;
    }
    
    public String getMethod()
    {
        return req.method().name();
    }
    
    public String getUrl()
    {
        return new QueryStringDecoder(req.uri()).path();
    }
    
    @Override
    public Object getAttribute(String var1) {
        return null;
    }
    
    @Override
    public Enumeration<String> getAttributeNames() {
        return null;
    }
    
    @Override
    public int getContentLength() {
        return 0;
    }
    
    @Override
    public long getContentLengthLong() {
        return 0;
    }
    
    @Override
    public String getContentType() {
        return null;
    }
    
    @Override
    public List<String> getParameterValues(String var1) {
        return getParameters().get(var1);
    }
    
    @Override
    public Map<String, List<String>> getParameters() {
        return new QueryStringDecoder(req.uri()).parameters();
    }
}
